You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
improve reporting of error in wrong inheritance for autoload script
This commit is contained in:
@@ -78,11 +78,11 @@ void OS_Unix::print_error(const char* p_function,const char* p_file,int p_line,c
|
|||||||
break;
|
break;
|
||||||
case ERR_WARNING:
|
case ERR_WARNING:
|
||||||
print("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n",p_function,err_details);
|
print("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n",p_function,err_details);
|
||||||
print("\E[0;33m At: %s:%i.\E[0m\n",p_file,p_line);
|
print("\E[0;33m At: %s:%i.\E[0m\n",p_file,p_line);
|
||||||
break;
|
break;
|
||||||
case ERR_SCRIPT:
|
case ERR_SCRIPT:
|
||||||
print("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m%s\n",p_function,err_details);
|
print("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m%s\n",p_function,err_details);
|
||||||
print("\E[0;35m At: %s:%i.\E[0m\n",p_file,p_line);
|
print("\E[0;35m At: %s:%i.\E[0m\n",p_file,p_line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1374,12 +1374,13 @@ bool Main::start() {
|
|||||||
} else if (res->is_type("Script")) {
|
} else if (res->is_type("Script")) {
|
||||||
Ref<Script> s = res;
|
Ref<Script> s = res;
|
||||||
StringName ibt = s->get_instance_base_type();
|
StringName ibt = s->get_instance_base_type();
|
||||||
|
bool valid_type = !ObjectTypeDB::is_type(ibt,"Node");
|
||||||
ERR_EXPLAIN("Script does not inherit a Node: "+path);
|
ERR_EXPLAIN("Script does not inherit a Node: "+path);
|
||||||
ERR_CONTINUE( !ObjectTypeDB::is_type(ibt,"Node") );
|
ERR_CONTINUE( !valid_type );
|
||||||
|
|
||||||
Object *obj = ObjectTypeDB::instance(ibt);
|
Object *obj = ObjectTypeDB::instance(ibt);
|
||||||
|
|
||||||
ERR_EXPLAIN("Cannot instance node for autoload type: "+String(ibt));
|
ERR_EXPLAIN("Cannot instance script for autoload, expected 'Node' inheritance, got: "+String(ibt));
|
||||||
ERR_CONTINUE( obj==NULL );
|
ERR_CONTINUE( obj==NULL );
|
||||||
|
|
||||||
n = obj->cast_to<Node>();
|
n = obj->cast_to<Node>();
|
||||||
|
|||||||
Reference in New Issue
Block a user