How do I run shell with custom Error handler? - cakephp

I have custom AppError class which starts with
App::import('Core', 'Error');
When I try to run any shell script I run into "Fatal error: cannot redeclare class ErrorHandler in ...\cake\libs\error". It seems the ErrorHandler for console is loaded...

Why don't you simply extend the ErrorHandler class if it is already loaded?
<?php
class AppError extends ErrorHandler {
}
?>

Related

"class constructors must be invoked with 'new'" when using Dexie in React

I am using Dexie with Gatsby, I try to create database in db.ts with the code below, but there is error class constructors must be invoked with 'new' pointing to the line super('newDB'). Any help for solving the error?
export class NewDB extends Dexie {
store0!: Table<Store0>;
constructor() {
super('newDB');
this.version(1).stores({
store0: '++id',
});
}
}
export const db = new NewDB();

Get "Cannot call a class as a function" when importing 2 css files in ReactJS

I am running ReactJS with Server-Side-Render on ASP.Net MVC. I also setup Webpack config. This code of my component works just fine:
import "../fine-uploader/fine-uploader.min.css";
But when I import another stylesheet, like this:
import "../fine-uploader/fine-uploader.min.css";
import "../../Content/fine-uploader/fine-uploader-custom.css";
It returns this error when opening the page with my component:
TypeError: Cannot call a class as a function
at _classCallCheck -> function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
Turns out I've to manually restart the Webpack build script command everytime I import something new. I get this error because I've been relying on the webpack-subresource-integrity to watches for changes and rebuild.

Trying to configure throws error

I am confused about aws-sdk for react, trying to configure it throws error which is a bit confusing, considering the object looks fine in the debugger, but the moment that I step over it throws error: TypeError: Unable to get property 'config' of undefined or null reference
the code:
import {AWS, CustomEvent, AMA} from 'aws-sdk';
class App extends Component {
constructor(props) {
debugger;
AWS.config.region = 'us-east-1';
...
I assumed that once imported the AWS included config object, and if I were to attach with debugger (at the debugger; line) the AWS object looks good and so does the AWS.config and further AWS.config.region is set to null, but if I step, it throws the above error.... Any thoughts what may be misconfigured?
I had the same issue, I solved it with:
import AWS from 'aws-sdk';
AWS.config.region = 'us-east-1';
For some reason it is the import { AWS } as opposed to import AWS that caused the error

JSF with google app engine. not sure how to call method in managedbean

I'm using google app engine with JSF. i want to call a function when user press that button:
<p:commandButton value="Ajax Submit" action="#{todo.test}" />
and I put todo under src->package test123.
package test123;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
#ManagedBean(name="todo")
#SessionScoped
public class Todo {
public void test(ActionEvent event){
System.out.println("lol");
}
}
but when i press button, error occurs:
sth like this:
javax.el.MethodNotFoundException: /Template/default.xhtml #39,38 action="#{todo.test}": Method not found: test.Todo#7929b073.test()
am i wrong? or do i need to do some configurations ?
Thanks
Use actionListener="#{todo.test}" or try:
public void test()
{
System.out.println("lol");
}
See here for more details: Differences between action and actionListener

ATK4 Fatal Error

Fatal error: Class 'h1' not found in /home/iracersr/public_html/atk4/lib/AbstractObject.php on line 131
I have installed the latest version and here is the code im using. Any suggestions?
<?php
class page_index extends Page {
function init(){
parent::init();
$p=$this;
//Get Articles
$articles=$this->add('Model_News')->getRows();
$p->add('h1')->set('Latest News');
foreach($articles as $article){
$content=$this->add('view',null,null,array('view/blog'));
$content->template->set('title',$article['title']);
$content->template->set('content',$article['content']);
}
}
}
It's case sensitive.
->add('H1');

Resources